package com.easyfun.healthmagicbox.comm.json;

import org.json.JSONException;
import org.json.JSONObject;

import com.easyfun.healthmagicbox.pojo.HeartBeatMessage;

public class ServerHeartBeatJsonWrapper <T extends JsonWrapper,E> 
	extends AbstractJsonWrapper<T,HeartBeatMessage>{

	public ServerHeartBeatJsonWrapper(HeartBeatMessage pp)
	{
		super(pp);
	}

	public ServerHeartBeatJsonWrapper()
	{
		
	}
 
    public void deserializeFromObj(JSONObject obj) throws JSONException {

    	if (mpp==null)
    		mpp = new HeartBeatMessage(obj.getString("personID"));
    	mpp.setSuggestionMaxID(obj.isNull("suggestionMaxID")?"":obj.getString("suggestionMaxID"));
    	mpp.setHidMaxID(obj.isNull("hidMaxID")?"":obj.getString("hidMaxID"));
    	mpp.setQuestionMaxID(obj.isNull("questionMaxID")?"":obj.getString("questionMaxID"));
    	mpp.setAlarmMaxID1(obj.isNull("alarmMaxID1")?"":obj.getString("alarmMaxID1"));
    	mpp.setAlarmMaxID2(obj.isNull("alarmMaxID2")?"":obj.getString("alarmMaxID2"));
    	mpp.setPictureMaxID(obj.isNull("pictureMaxID")?"":obj.getString("pictureMaxID"));
    	mpp.setUtopIDModifiedDate(obj.isNull("utopIDModifiedDate")?"":obj.getString("utopIDModifiedDate"));
    	mpp.setProfileModifiedDate(obj.isNull("profileModifiedDate")?"":obj.getString("profileModifiedDate"));
    	mpp.setUsername(obj.isNull("username")?"":obj.getString("username"));
    }
 
    
 
    public JSONObject serializeToObj() throws JSONException {
        JSONObject serializedObj = new JSONObject();
        serializedObj.put("personID", mpp.getPersonID());
        serializedObj.put("suggestionMaxID", mpp.getSuggestionMaxID());
        serializedObj.put("hidMaxID", mpp.getHidMaxID());
        serializedObj.put("questionMaxID", mpp.getQuestionMaxID());
        serializedObj.put("alarmMaxID1", mpp.getAlarmMaxID1());
        serializedObj.put("alarmMaxID2", mpp.getAlarmMaxID2());
        serializedObj.put("pictureMaxID", mpp.getPictureMaxID());
        serializedObj.put("utopIDModifiedDate", mpp.getUtopIDModifiedDate());
        serializedObj.put("profileModifiedDate", mpp.getProfileModifiedDate());
        serializedObj.put("username", mpp.getUsername());
 
        return serializedObj;
    }

}
